[OpenGl] Loading new texture into already defined texture name

Posted by Dan Vogel on Stack Overflow See other posts from Stack Overflow or by Dan Vogel
Published on 2008-12-01T21:02:23Z Indexed on 2010/04/02 3:03 UTC
Read the original article Hit count: 540

Filed under:
|

I have an OpenGl program in which I am displaying an image using textures. I want to be able to load a new image to be displayed.

In my Init function I call:

Gl.glGenTextures(1, mTextures);

Since only one image will be displayed at time, I am using the same texture name for each image.

Each time a new image is loaded I call the following:

Gl.glBindTexture(Gl.GL_TEXTURE_2D, mTexture[0]);

Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_LUMINANCE, mTexSizeX, mTexSizeY, 0, Gl.GL_LUMINANCE, Gl.GL_UNSIGNED_SHORT, mTexBuffer);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR);   
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);

The first image will display as expected. However, all images load after the first, display as all black.

What am I doing wrong?

© Stack Overflow or respective owner

Related posts about opengl

Related posts about textures